<template>
	<view>
		<view class="wholeWh">
			<block v-if="isSuccNum == 1">
				<image class="cpImg" src="../../../static/images/xlcp/cpComp.png"></image>
				<view class="compTit">恭喜,您已测试完成!</view>
				<!-- <button class="comBtn" @tap="backUpClick">返回</button> -->
			</block>
			<block v-else-if="isSuccNum == 0">
				<image class="cpImg" src="../../../static/images/xlcp/cpFail.png"></image>
				<view class="compTit">测试失败,{{failTxt}}</view>
				<!-- <button class="comBtn" @tap="backUpClick">返回</button> -->
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				fromPage:'',
				isSuccNum:-1,//1 完成 0失败
				failTxt:'',
				clickFlag:false
			}
		},
		onLoad(options){
			/*
				cpDetPage->测评详情 
				myCpRec 测评订单 //
				gyDetPage 干预详情试测进来
			*/
			this.fromPage = options.fromPage;
			this.isSuccNum = Number(options.isSuccNum);
			this.failTxt = options.failTxt;
		},
		onUnload(){
			uni.removeStorageSync('userCpInfo');
			if(this.fromPage != 'myCpRec'){
				if(!this.clickFlag){
					wx.disableAlertBeforeUnload();
					this.backUp();
				}
			}
		},
		methods:{
			backUpClick(){
				this.clickFlag = true;
				wx.disableAlertBeforeUnload();
				this.backUp();
			},
			backUp(){
				var delta = 0;
				if(this.fromPage == 'cpDetPage'){
					delta = 2;
					let pages = getCurrentPages();
					let prevPage = pages[pages.length - 4];
					prevPage.$vm.isRefreshFlag = true;
				}else if(this.fromPage == 'gyDetPage'){
					delta = 2;
					let pages = getCurrentPages();
					let prevPage = pages[pages.length - 3];
					prevPage.$vm.isRefreshFlag = true;
				}else{
					delta:1
				}
				uni.navigateBack({
					delta
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/scss/cpResult.scss'; 
</style>